//
//  YYTransferController.m
//  Xanthium
//
//  Created by yangyongMac on 2018/7/5.
//  Copyright © 2018年 GuanQinghao. All rights reserved.
//

#import "YYTransferController.h"
#import "YYTransferView.h"
#import "GQHHeader.h"
#import "TZImagePickerController.h"

@interface YYTransferController () <TZImagePickerControllerDelegate, YYTransferViewDelegate>

@property (nonatomic, strong) YYTransferView * rootView;

@end

@implementation YYTransferController


- (void)viewDidLoad
{
    [super viewDidLoad];
    
}

#pragma mark --Lifecycle
- (void)loadView
{
    DLog();
    
    self.rootView = [[YYTransferView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.rootView.delegate = self;
    self.view = self.rootView;
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    DLog();
    
    self.qh_titleLabel.text = @"换车";
    [self.qh_rightButton setHidden:YES];
    self.automaticallyAdjustsScrollViewInsets = NO;
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    DLog();
    
}

- (void)addImageAction:(UIButton *)sender
{
    GQH_WEAKSELF;
    TZImagePickerController *imagePickerController = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:self];
    [imagePickerController setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
        DLog(@"选择图片完成,上传图片");
        
        if (photos && photos.count > 0) {
            
            [sender setBackgroundImage:photos[0] forState:0];
//            NSData * data = UIImagePNGRepresentation(photos[0]);
//            if (sender.tag == 10)
//            {
//                [weakSelf.rootView.parmasDic setObject:data forKey:@"carQrivingLicPhoto"];
//            }
//            else if (sender.tag == 20)
//            {
//                [weakSelf.rootView.parmasDic setObject:data forKey:@"roadTraCerLic"];            }
//            else if (sender.tag == 30)
//            {
//                [weakSelf.rootView.parmasDic setObject:data forKey:@"CarPhoto"];
//            }
//            else if (sender.tag == 40)
//            {
//                [weakSelf.rootView.parmasDic setObject:data forKey:@"CarPhoto1"];
//            }
        }
    }];
    [self presentViewController:imagePickerController animated:YES completion:nil];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
